package com.ddpt.platform.common.exception;

/**
 * 异常code
 */
public enum ErrorEnum implements ErrorCodeDefinition {

	PUBLIC_WECHAT_TEMPLATE_ERROR(10001, "微信公众号模板消息列表获取失败"),

	OPEN_API_MODIFY_USER_INFORMATION_PARAM_ERROR(90001, "开放接口修改用户信息时,传递参数不合法"),
	OPEN_API_MODIFY_USER_INFORMATION_ERROR(900002, "开放接口修改用户信息失败"),

	ID_MISS(20301, "客群id不能为空"),
	INVALID_EXPIRATION_TIME(20302, "画布失效时间不能小于当前时间"),

	PARAM_MISS(20401, "尚有信息未填写或填写错误，请先填写或修改"),
	DUPLICATE_NAME(20402, "重复名称错误"),
	DUPLICATE_STRATEGY_NAME(20403, "步骤重复名称错误"),
	REFERENCE_UPDATE_FAIL(20404, "被画布引用,无法修改"),
	SAAS_REFERENCE_UPDATE_FAIL(20404, "被画布模板引用,无法修改"),
	REFERENCE_DELETE_FAIL(20404, "被画布引用,无法删除"),
	SAAS_REFERENCE_DELETE_FAIL(20404, "被画布模板引用,无法删除"),
	IMAGE_CODE_FAIL(28391, "验证码校验失败"),
	IMAGE_CODE_INPUT_FAIL(28391, "验证码错误"),
	IMAGE_CODE_PAST(28391, "验证码已过期，请重新登录"),
	NOT_TINGTANG_USER(28392, "您还不是厅堂用户"),
	//====================支付异常============================
    PAYMENT_TYPE_NOT_EXIST(30001, "支付方式未配置"),

	//====================用户异常=============================
	user_not_login(9999,"用户未登陆"),
	user_login_limit(9998,"抱歉，您为非邀约客户"),
	not_allowed_login_type(9997,"不允许的登录方式"),
	// =================== 系统异常 ============================
	aes_decrypt_error(101,"数据解密异常"),
	aes_encrypt_error(102,"数据加密异常"),
	PARAM_ERROR(103,"参数错误"),
	CRITICAL_PARAM_DEFICIENCY(104, "尚有信息未填写或填写错误，请先填写或修改"),
	USERNAME_OR_PASSWORD_ERROR(105,"用户名或密码错误"),
	ADMIN_INVALID(106,"账号已被禁用，请联系管理员"),
	MERCHANT_ALREADY_EXIST(106,"商户已存在，请重新输入"),
	MERCHANT_NOT_EXIST_OR_INVALID(106,"商户不存在或已禁用"),
	MERCHANT_EXPIRED(106,"商户服务已到期"),
	CURRENT_ROLE_INVALID(106,"当前账号关联的角色不存在或已删除，请联系管理员"),
	ROLE_DEFICIENCY(106,"当前帐号未关联角色，请联系管理员"),
	ADMIN_USERNAME_DUPLICATE(107,"管理员账号已存在，请重新输入"),
	MERCHANT_ADMIN_USERNAME_FORMAT_ERROR(108,"超管账号必须为4至16位字母或数字"),
	MERCHANT_ADMIN_PASSWORD_FORMAT_ERROR(109,"超管密码长度必须为6至20位"),
	MERCHANT_ADMIN_CANNOT_EDIT(110,"超管账号不可更改"),
	MERCHANT_SERVICE_ONLY_ADD(110,"商户应用权限只能添加，不能删除"),
	MERCHANT_INS_NOT_EXIST_OR_INVALID(111,"商户机构不存在或已禁用"),
	INS_MERCHANT_SEVICE_BEYOND(112,"机构应用权限超出上级应用权限"),
	ROLE_NOT_EMPTY(113,"角色下有关联员工，无法删除"),
	PERMISSION_NOT_EMPTY(114,"请先删除子权限"),
	INS_HVAE_NO_SERVICE(115,"您所在的机构无应用权限"),
	HAVE_NONE_PERMISSION(116,"您没有任何菜单权限，请联系管理员"),
	CANNOT_CREATE_TOP_INS(117,"不能创建一级机构"),
	NO_QUERY_DATA(118,"未找到相关数据"),
	PAGE_ERROR(1000015, "页码不能为空且必须大于0"),
	PAGE_SIZE_ERROR(1000016, "每页条数不能为空且必须大于0"),
	TODAY_ALREADY_SIGN(2000001,"今日已完成签到，请勿重复"),
	ALL_SIGN_ACCOM(2000002,"已完成所有签到任务"),
	CANNOT_PROMOTE_SELF(2000101,"不能为自己助力"),
	// =================== 数据看板异常 ============================
	CANT_FIND_TABLE(10001, "找不到数据表"),
	CANT_FIND_COLUMN(10002, "找不到该指标"),
	NOT_TODAY_DATA(10003, "非今日数据不存储"),

	// =================== 活动状态相关 =============================
	STATUS_MISMATCH(20001, "当前数据状态不匹配"),
	EXPORT_HAV(11111, "已存在该导出"),
	error(-1, "系统繁忙");


	/**
	 * 编码值
	 */
	private final int code;
	/**
	 * 备注，提示
	 */
	private final String remark;

	/**
	 * 异常枚举类
	 *
	 * @param code
	 *            编码值
	 * @param remark
	 *            备注，提示
	 */
	private ErrorEnum(int code, String remark) {
		this.code = code;
		this.remark = remark;
	}

	/**
	 * 依据异常编码值获取异常
	 */
	public static ErrorEnum getErrorCode(int code) {
		for (ErrorEnum ec : ErrorEnum.values()) {
			if (ec.getCode() == code) {
				return ec;
			}
		}
		return error;
	}

	@Override
	public int getCode() {
		return code;
	}

	@Override
	public String getRemark() {
		return remark;
	}
}
